package com.pengtu.web.measure.wt07;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.entity.receive.Entrust;
import com.pengtu.entity.trial.Order;
import com.pengtu.service.receive.TrialCommonManager;
import com.pengtu.service.trial.TrialManager;
import com.pengtu.utils.web.Struts2Utils;
import com.pengtu.web.BaseActionSupport;

public class Order07Action extends BaseActionSupport<Order> {

	/**
	 * serialVersionUID:TODO
	 * 
	 * @since 1.0.0
	 */

	private static final long serialVersionUID = 1L;
	private String id;
	private Entrust entrust;
	private Order order;
	private TrialCommonManager trialCommonManager;
	private TrialManager trialManager;
	private Page<Order> page = new Page<Order>(10);

	@Override
	public Order getModel() {
		// TODO Auto-generated method stub
		return order;
	}

	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public String all() throws Exception {
		QueryFilter filters = QueryFilter.buildFromHttpRequest(Struts2Utils
				.getRequest());
		// 设置默认排序方式
		if (!page.isOrderBySetted()) {
			page.setOrderBy("createDate");
			page.setOrder(Page.DESC);
		}
		filters.addFilter("trialtype", "WT07");
		filters.addFilter("type", order.getType());
		page = trialManager.findByOrderPage(page, filters);
		System.out.println(page.getResult().size());
		return SUCCESS;
	}

	public void prepareAll() throws Exception {
		prepareModel();
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
		if (StringUtils.isNotEmpty(id)) {
			order = trialManager.findByOrder("id", id);
		} else {
			order = new Order();
		}
	}

	/**
	 * id
	 * 
	 * @return the id
	 * @since 1.0.0
	 */

	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	@Autowired
	public void setTrialCommonManager(TrialCommonManager trialCommonManager) {
		this.trialCommonManager = trialCommonManager;
	}

	/**
	 * entrust
	 * 
	 * @return the entrust
	 * @since 1.0.0
	 */

	public Entrust getEntrust() {
		return entrust;
	}

	/**
	 * @param entrust
	 *            the entrust to set
	 */
	public void setEntrust(Entrust entrust) {
		this.entrust = entrust;
	}

	/**
	 * page
	 * 
	 * @return the page
	 * @since 1.0.0
	 */

	public Page<Order> getPage() {
		return page;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(Page<Order> page) {
		this.page = page;
	}

	/**
	 * @param trialManager
	 *            the trialManager to set
	 */
	@Autowired
	public void setTrialManager(TrialManager trialManager) {
		this.trialManager = trialManager;
	}

}
